<?php
$user="junemann_nl";
$password="cVXJ6WUn";
$database="junemann_nl";

$con = mysql_connect("localhost",$user,$password);
if(!$con)
{
	die("Unable to connect to server");
}

mysql_select_db($database, $con);

$id = $_GET["id"];
$name = $_GET["name"];
$pos = $_GET["pos"];

echo "<?xml version='1.0' encoding='UTF-8'?><characters>";

if($id == "-1")
{
   // New player. Insert.
   mysql_query("INSERT INTO null_sk_characters(Pos, Name) VALUES(" .$pos. ", '" .$name. "')");
   
   // Return ID for check and update
   $result = mysql_query("SELECT * FROM null_sk_characters ORDER BY ID DESC LIMIT 0 , 1");
   while($row = mysql_fetch_array($result))
   {
      echo "<character id='". $row['ID'] ."' pos='" . $row['Pos'] . "' name='" . $row['Name'] . "' />";
   }
 }
 else
 {
   // Update.
   mysql_query("UPDATE null_sk_characters SET Pos = " . $pos . ", Name = '" . $name . "' WHERE ID = " .$id);
   
   // Return ID for check and update
   $result = mysql_query("SELECT * FROM null_sk_characters WHERE ID = " .$id);
   while($row = mysql_fetch_array($result))
   {
      echo "<character id='". $row['ID'] ."' pos='" . $row['Pos'] . "' name='" . $row['Name'] . "' />";
   }   
 }
 
echo "</characters>";

mysql_close($con);
?>